#pragma once


// COptionDlg dialog

class COptionDlg : public CDialog
{
	DECLARE_DYNAMIC(COptionDlg)

public:
	COptionDlg(CWnd* pParent = NULL);   // standard constructor
	virtual ~COptionDlg();

	LPCTSTR lpRegKey;
	LPCTSTR lpRegNames[37];
	DWORD dwRegValues[37];
	CString csTempPath;
	CString csSavePath;

	void enableControlArray(UINT *idList, int count, BOOL bEnabled=TRUE);
	void applyEnableStatus();
	void SaveToRegistry(bool bUpdateData);
	void SetRegValueTCHAR(HKEY hkey, LPCTSTR tcName, TCHAR *tcData);
	void SetRegValueDWORD(HKEY hkey, LPCTSTR tcName, DWORD dwNum);
	void removeHKCUKey(LPCTSTR tcKey);
	BOOL OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult);

// Dialog Data
	enum { IDD = IDD_OPTION };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
public:
	int m_iIDevice;
	int m_iConversionMode;
	int m_iConversionProfile;
	int m_iRotate;
	int m_iPAR;
	int m_bForceReEncodeAAC;
	int m_iAudioOrder;
	int m_iAudioBR;
	int m_iFontSize;
	int m_iSrtLang;
	int m_iDefaultLangA;
	int m_iDefaultLangS;
	int m_iKeepTempFiles;
	UINT m_uFfmpegThreads;
	double m_dNormalizeAudioInDB;
	BOOL m_bDeinterlace;
	BOOL m_bKeepRotate;
	BOOL m_bKeepPrefixOnlyWhenNeeded;
	BOOL m_bCopyOriginDate;
	BOOL m_b4GBonly;
	BOOL m_bCheck30fps;
	BOOL m_bFfmpegThreads;
	BOOL m_bBothAudio;
	BOOL m_bAudioOrder;
	BOOL m_bNormalizeAudio;
	BOOL m_bDontDownmixAudio;
	BOOL m_bMuxAC3;
	BOOL m_bExtract2SRT;
	BOOL m_bBurnSubtitle;
	BOOL m_bBothSubtitles;
	BOOL m_bSrtLang;
	BOOL m_bDefaultLangA;
	BOOL m_bDefaultLangS;
	BOOL m_bUseSaveFolder;
	BOOL m_bPathFirst;
	afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
	afx_msg void OnSelchangeComboMachine();
	afx_msg void OnSelchangeConversionMode();
	afx_msg void OnClickedCheckFfmpegThreads();
	afx_msg void OnClickedCheckChooseAudio();
	afx_msg void OnClickedCheckNorm();
	afx_msg void OnClickedCheckBurnSubtitle();
	afx_msg void OnClickedCheckSRTLangCode();
	afx_msg void OnClickedCheckDefaultLangA();
	afx_msg void OnClickedCheckDefaultLangS();
	afx_msg void OnClickedCheckUseSaveFolder();
	afx_msg void OnClickedButtonSetTempFolder();
	afx_msg void OnClickedButtonSetSaveFolder();
	afx_msg void OnClickedButtonSaveToRegistry();
	afx_msg void OnClickedButtonInitValues();

	virtual BOOL OnInitDialog();

protected:
	inline DWORD decibel2DWORD(double decibel) {
		bool negative = (decibel<0.0);
		if (negative) decibel = -decibel;

		DWORD ret = static_cast<DWORD>(decibel*1000000);
		ret &= (~1);

		if (negative) ret++;

		return ret;
	}
public:
	BOOL m_bIgnoreUTC;
	afx_msg void OnClickedCheckCopyFileDate();
};
